﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using Model;

namespace DAL
{
    public class SystemParameterDAL
    {

        /// <summary>
        /// 获取一条数据
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public SystemParameter GetModel(string type)
        {
            return DBUtility.MySqlHelper.ExecuteDataReaderModel<SystemParameter>("SELECT * FROM `systemparameter` where Type=@type", new MySqlParameter("@type", type));
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(SystemParameter model)
        {
            MySqlParameter[] para = {
                new MySqlParameter("@type",model.Type),
                new MySqlParameter("@value",model.Value)
            };
            return DBUtility.MySqlHelper.ExecuteNonQuery("update systemparameter set Value=@value where Type=@Type", para);
        }

    }
}
